package com.jlect.swebing.util.client;

/**
 * String helper
 * @author Sergey Kozmin
 * @since 11.11.2007 20:49:39
 */
public class Strings {
    private static final String PX_PREFIX = "px";

    public static String toPixelString(int pixel) {
        return pixel + PX_PREFIX;
    }

    public static int pixelToString(String pixel) {
        int index;
        if((index = pixel.indexOf(PX_PREFIX)) > 0) {
            return Integer.parseInt(pixel.substring(0, index));
        } else {
            return 0;
//            throw new IllegalArgumentException("Could not find [" + PX_PREFIX + "] in [" + pixel + "] size. ");
        }
    }

    public static boolean isEmpty(String string) {
        return string == null || "".equalsIgnoreCase(string);
    }

    public static boolean isEqual(String first, String second) {
        return first == null ? second == null : first.equalsIgnoreCase(second);
    }
}
